package com.ssky.bean.validator.util;


/**
 * @Author: ssky
 * @Date: 2021/07/18
 * @Description:
 */
public class ValueUtil {
    public static boolean isBlank(String str) {
        if (str == null || "".equals(str)) {
            return true;
        }
        return false;
    }


    public static boolean isBlank(Object obj) {
        if (obj == null || "".equals(obj.toString())) {
            return true;
        }
        return false;
    }


    public static boolean isNull(Object obj) {
        if (obj == null)
            return true;
        return false;
    }


    public static String convertBlankToNull(String str) {
        if (isBlank(str))
            return null;
        return str;
    }




    public static Long convertToLong(String str) {
        if (isBlank(str))
            return null;
        return Long.valueOf(Long.parseLong(str));
    }


    public static Integer convertToInteger(String str) {
        if (isBlank(str))
            return null;
        return Integer.valueOf(Integer.parseInt(str));
    }


    public static Short convertToShort(String str) {
        if (isBlank(str))
            return null;
        return Short.valueOf(Short.parseShort(str));
    }


    public static Double convertToDouble(String str) {
        if (isBlank(str))
            return null;
        return Double.valueOf(Double.parseDouble(str));
    }


    public static Character convertToCharacter(String str) {
        if (isBlank(str))
            return null;
        return Character.valueOf(str.charAt(0));
    }

    public static boolean compareHasEquals(String srcStr, String tag1) {
        if (srcStr == null)
            return false;
        if (srcStr.equals(tag1))
            return true;
        return false;
    }

    public static boolean compareHasEquals(String srcStr, String tag1, String tag2) {
        if (srcStr == null)
            return false;
        if (srcStr.equals(tag1))
            return true;
        if (srcStr.equals(tag2))
            return true;
        return false;
    }

    public static boolean compareHasEquals(String srcStr, String tag1, String tag2, String tag3) {
        if (srcStr == null)
            return false;
        if (srcStr.equals(tag1))
            return true;
        if (srcStr.equals(tag2))
            return true;
        if (srcStr.equals(tag3))
            return true;
        return false;
    }

    public static boolean compareHasEquals(String srcStr, String tag1, String tag2, String tag3, String tag4) {
        if (srcStr == null)
            return false;
        if (srcStr.equals(tag1))
            return true;
        if (srcStr.equals(tag2))
            return true;
        if (srcStr.equals(tag3))
            return true;
        if (srcStr.equals(tag4))
            return true;
        return false;
    }

    public static boolean compareHasEquals(String srcStr, String tag1, String tag2, String tag3, String tag4, String tag5) {
        if (srcStr == null)
            return false;
        if (srcStr.equals(tag1))
            return true;
        if (srcStr.equals(tag2))
            return true;
        if (srcStr.equals(tag3))
            return true;
        if (srcStr.equals(tag4))
            return true;
        if (srcStr.equals(tag5))
            return true;
        return false;
    }


    public static boolean compareHasEquals(String srcStr, String tag1, String tag2, String tag3, String tag4, String tag5, String tag6) {
        if (srcStr == null)
            return false;
        if (srcStr.equals(tag1))
            return true;
        if (srcStr.equals(tag2))
            return true;
        if (srcStr.equals(tag3))
            return true;
        if (srcStr.equals(tag4))
            return true;
        if (srcStr.equals(tag5))
            return true;
        if (srcStr.equals(tag6))
            return true;
        return false;
    }


    public static boolean compareHasEquals(String srcStr, String tag1, String tag2, String tag3, String tag4, String tag5, String tag6, String tag7) {
        if (srcStr == null)
            return false;
        if (srcStr.equals(tag1))
            return true;
        if (srcStr.equals(tag2))
            return true;
        if (srcStr.equals(tag3))
            return true;
        if (srcStr.equals(tag4))
            return true;
        if (srcStr.equals(tag5))
            return true;
        if (srcStr.equals(tag6))
            return true;
        if (srcStr.equals(tag7))
            return true;
        return false;
    }


    public static boolean compareHasEquals(String srcStr, String tag1, String tag2, String tag3, String tag4, String tag5, String tag6, String tag7, String tag8) {
        if (srcStr == null)
            return false;
        if (srcStr.equals(tag1))
            return true;
        if (srcStr.equals(tag2))
            return true;
        if (srcStr.equals(tag3))
            return true;
        if (srcStr.equals(tag4))
            return true;
        if (srcStr.equals(tag5))
            return true;
        if (srcStr.equals(tag6))
            return true;
        if (srcStr.equals(tag7))
            return true;
        if (srcStr.equals(tag8))
            return true;
        return false;
    }


    public static boolean compareHasEquals(String srcStr, String tag1, String tag2, String tag3, String tag4, String tag5, String tag6, String tag7, String tag8, String tag9) {
        if (srcStr == null)
            return false;
        if (srcStr.equals(tag1))
            return true;
        if (srcStr.equals(tag2))
            return true;
        if (srcStr.equals(tag3))
            return true;
        if (srcStr.equals(tag4))
            return true;
        if (srcStr.equals(tag5))
            return true;
        if (srcStr.equals(tag6))
            return true;
        if (srcStr.equals(tag7))
            return true;
        if (srcStr.equals(tag8))
            return true;
        if (srcStr.equals(tag9))
            return true;
        return false;
    }


    public static boolean compareHasEquals(String srcStr, String tag1, String tag2, String tag3, String tag4, String tag5, String tag6, String tag7, String tag8, String tag9, String tag10) {
        if (srcStr == null)
            return false;
        if (srcStr.equals(tag1))
            return true;
        if (srcStr.equals(tag2))
            return true;
        if (srcStr.equals(tag3))
            return true;
        if (srcStr.equals(tag4))
            return true;
        if (srcStr.equals(tag5))
            return true;
        if (srcStr.equals(tag6))
            return true;
        if (srcStr.equals(tag7))
            return true;
        if (srcStr.equals(tag8))
            return true;
        if (srcStr.equals(tag9))
            return true;
        if (srcStr.equals(tag10))
            return true;
        return false;
    }

    public static boolean hasNull(Object obj1) {
        if (obj1 == null)
            return true;
        return false;
    }

    public static boolean hasNull(Object obj1, Object obj2) {
        if (obj1 == null)
            return true;
        if (obj2 == null)
            return true;
        return false;
    }

    public static boolean hasNull(Object obj1, Object obj2, Object obj3) {
        if (obj1 == null)
            return true;
        if (obj2 == null)
            return true;
        if (obj3 == null)
            return true;
        return false;
    }

    public static boolean hasNull(Object obj1, Object obj2, Object obj3, Object obj4) {
        if (obj1 == null)
            return true;
        if (obj2 == null)
            return true;
        if (obj3 == null)
            return true;
        if (obj4 == null)
            return true;
        return false;
    }

    public static boolean hasNull(Object obj1, Object obj2, Object obj3, Object obj4, Object obj5) {
        if (obj1 == null)
            return true;
        if (obj2 == null)
            return true;
        if (obj3 == null)
            return true;
        if (obj4 == null)
            return true;
        if (obj5 == null)
            return true;
        return false;
    }

    public static boolean hasNull(Object obj1, Object obj2, Object obj3, Object obj4, Object obj5, Object obj6) {
        if (obj1 == null)
            return true;
        if (obj2 == null)
            return true;
        if (obj3 == null)
            return true;
        if (obj4 == null)
            return true;
        if (obj5 == null)
            return true;
        if (obj6 == null)
            return true;
        return false;
    }

    public static boolean hasNull(Object obj1, Object obj2, Object obj3, Object obj4, Object obj5, Object obj6, Object obj7) {
        if (obj1 == null)
            return true;
        if (obj2 == null)
            return true;
        if (obj3 == null)
            return true;
        if (obj4 == null)
            return true;
        if (obj5 == null)
            return true;
        if (obj6 == null)
            return true;
        if (obj7 == null)
            return true;
        return false;
    }


    public static boolean hasNull(Object obj1, Object obj2, Object obj3, Object obj4, Object obj5, Object obj6, Object obj7, Object obj8) {
        if (obj1 == null)
            return true;
        if (obj2 == null)
            return true;
        if (obj3 == null)
            return true;
        if (obj4 == null)
            return true;
        if (obj5 == null)
            return true;
        if (obj6 == null)
            return true;
        if (obj7 == null)
            return true;
        if (obj8 == null)
            return true;
        return false;
    }


    public static boolean hasNull(Object obj1, Object obj2, Object obj3, Object obj4, Object obj5, Object obj6, Object obj7, Object obj8, Object obj9) {
        if (obj1 == null)
            return true;
        if (obj2 == null)
            return true;
        if (obj3 == null)
            return true;
        if (obj4 == null)
            return true;
        if (obj5 == null)
            return true;
        if (obj6 == null)
            return true;
        if (obj7 == null)
            return true;
        if (obj8 == null)
            return true;
        if (obj9 == null)
            return true;
        return false;
    }


    public static boolean hasNull(Object obj1, Object obj2, Object obj3, Object obj4, Object obj5, Object obj6, Object obj7, Object obj8, Object obj9, Object obj10) {
        if (obj1 == null)
            return true;
        if (obj2 == null)
            return true;
        if (obj3 == null)
            return true;
        if (obj4 == null)
            return true;
        if (obj5 == null)
            return true;
        if (obj6 == null)
            return true;
        if (obj7 == null)
            return true;
        if (obj8 == null)
            return true;
        if (obj9 == null)
            return true;
        if (obj10 == null)
            return true;
        return false;
    }

    public static boolean hasNotNull(Object obj1) {
        if (obj1 != null)
            return true;
        return false;
    }

    public static boolean hasNotNull(Object obj1, Object obj2) {
        if (obj1 != null)
            return true;
        if (obj2 != null)
            return true;
        return false;
    }

    public static boolean hasNotNull(Object obj1, Object obj2, Object obj3) {
        if (obj1 != null)
            return true;
        if (obj2 != null)
            return true;
        if (obj3 != null)
            return true;
        return false;
    }

    public static boolean hasNotNull(Object obj1, Object obj2, Object obj3, Object obj4) {
        if (obj1 != null)
            return true;
        if (obj2 != null)
            return true;
        if (obj3 != null)
            return true;
        if (obj4 != null)
            return true;
        return false;
    }

    public static boolean hasNotNull(Object obj1, Object obj2, Object obj3, Object obj4, Object obj5) {
        if (obj1 != null)
            return true;
        if (obj2 != null)
            return true;
        if (obj3 != null)
            return true;
        if (obj4 != null)
            return true;
        if (obj5 != null)
            return true;
        return false;
    }

    public static boolean hasNotNull(Object obj1, Object obj2, Object obj3, Object obj4, Object obj5, Object obj6) {
        if (obj1 != null)
            return true;
        if (obj2 != null)
            return true;
        if (obj3 != null)
            return true;
        if (obj4 != null)
            return true;
        if (obj5 != null)
            return true;
        if (obj6 != null)
            return true;
        return false;
    }

    public static boolean hasNotNull(Object obj1, Object obj2, Object obj3, Object obj4, Object obj5, Object obj6, Object obj7) {
        if (obj1 != null)
            return true;
        if (obj2 != null)
            return true;
        if (obj3 != null)
            return true;
        if (obj4 != null)
            return true;
        if (obj5 != null)
            return true;
        if (obj6 != null)
            return true;
        if (obj7 != null)
            return true;
        return false;
    }


    public static boolean hasNotNull(Object obj1, Object obj2, Object obj3, Object obj4, Object obj5, Object obj6, Object obj7, Object obj8) {
        if (obj1 != null)
            return true;
        if (obj2 != null)
            return true;
        if (obj3 != null)
            return true;
        if (obj4 != null)
            return true;
        if (obj5 != null)
            return true;
        if (obj6 != null)
            return true;
        if (obj7 != null)
            return true;
        if (obj8 != null)
            return true;
        return false;
    }


    public static boolean hasNotNull(Object obj1, Object obj2, Object obj3, Object obj4, Object obj5, Object obj6, Object obj7, Object obj8, Object obj9) {
        if (obj1 != null)
            return true;
        if (obj2 != null)
            return true;
        if (obj3 != null)
            return true;
        if (obj4 != null)
            return true;
        if (obj5 != null)
            return true;
        if (obj6 != null)
            return true;
        if (obj7 != null)
            return true;
        if (obj8 != null)
            return true;
        if (obj9 != null)
            return true;
        return false;
    }


    public static boolean hasNotNull(Object obj1, Object obj2, Object obj3, Object obj4, Object obj5, Object obj6, Object obj7, Object obj8, Object obj9, Object obj10) {
        if (obj1 != null)
            return true;
        if (obj2 != null)
            return true;
        if (obj3 != null)
            return true;
        if (obj4 != null)
            return true;
        if (obj5 != null)
            return true;
        if (obj6 != null)
            return true;
        if (obj7 != null)
            return true;
        if (obj8 != null)
            return true;
        if (obj9 != null)
            return true;
        if (obj10 != null)
            return true;
        return false;
    }

    public static boolean hasBlank(String str1) {
        if (isBlank(str1))
            return true;
        return false;
    }

    public static boolean hasBlank(String str1, String str2) {
        if (isBlank(str1))
            return true;
        if (isBlank(str2))
            return true;
        return false;
    }

    public static boolean hasBlank(String str1, String str2, String str3) {
        if (isBlank(str1))
            return true;
        if (isBlank(str2))
            return true;
        if (isBlank(str3))
            return true;
        return false;
    }

    public static boolean hasBlank(String str1, String str2, String str3, String str4) {
        if (isBlank(str1))
            return true;
        if (isBlank(str2))
            return true;
        if (isBlank(str3))
            return true;
        if (isBlank(str4))
            return true;
        return false;
    }

    public static boolean hasBlank(String str1, String str2, String str3, String str4, String str5) {
        if (isBlank(str1))
            return true;
        if (isBlank(str2))
            return true;
        if (isBlank(str3))
            return true;
        if (isBlank(str4))
            return true;
        if (isBlank(str5))
            return true;
        return false;
    }

    public static boolean hasBlank(String str1, String str2, String str3, String str4, String str5, String str6) {
        if (isBlank(str1))
            return true;
        if (isBlank(str2))
            return true;
        if (isBlank(str3))
            return true;
        if (isBlank(str4))
            return true;
        if (isBlank(str5))
            return true;
        if (isBlank(str6))
            return true;
        return false;
    }

    public static boolean hasBlank(String str1, String str2, String str3, String str4, String str5, String str6, String str7) {
        if (isBlank(str1))
            return true;
        if (isBlank(str2))
            return true;
        if (isBlank(str3))
            return true;
        if (isBlank(str4))
            return true;
        if (isBlank(str5))
            return true;
        if (isBlank(str6))
            return true;
        if (isBlank(str7))
            return true;
        return false;
    }


    public static boolean hasBlank(String str1, String str2, String str3, String str4, String str5, String str6, String str7, String str8) {
        if (isBlank(str1))
            return true;
        if (isBlank(str2))
            return true;
        if (isBlank(str3))
            return true;
        if (isBlank(str4))
            return true;
        if (isBlank(str5))
            return true;
        if (isBlank(str6))
            return true;
        if (isBlank(str7))
            return true;
        if (isBlank(str8))
            return true;
        return false;
    }


    public static boolean hasBlank(String str1, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9) {
        if (isBlank(str1))
            return true;
        if (isBlank(str2))
            return true;
        if (isBlank(str3))
            return true;
        if (isBlank(str4))
            return true;
        if (isBlank(str5))
            return true;
        if (isBlank(str6))
            return true;
        if (isBlank(str7))
            return true;
        if (isBlank(str8))
            return true;
        if (isBlank(str9))
            return true;
        return false;
    }


    public static boolean hasBlank(String str1, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9, String str10) {
        if (isBlank(str1))
            return true;
        if (isBlank(str2))
            return true;
        if (isBlank(str3))
            return true;
        if (isBlank(str4))
            return true;
        if (isBlank(str5))
            return true;
        if (isBlank(str6))
            return true;
        if (isBlank(str7))
            return true;
        if (isBlank(str8))
            return true;
        if (isBlank(str9))
            return true;
        if (isBlank(str10))
            return true;
        return false;
    }

    public static boolean hasNotBlank(String str1) {
        if (!isBlank(str1))
            return true;
        return false;
    }

    public static boolean hasNotBlank(String str1, String str2) {
        if (!isBlank(str1))
            return true;
        if (!isBlank(str2))
            return true;
        return false;
    }

    public static boolean hasNotBlank(String str1, String str2, String str3) {
        if (!isBlank(str1))
            return true;
        if (!isBlank(str2))
            return true;
        if (!isBlank(str3))
            return true;
        return false;
    }

    public static boolean hasNotBlank(String str1, String str2, String str3, String str4) {
        if (!isBlank(str1))
            return true;
        if (!isBlank(str2))
            return true;
        if (!isBlank(str3))
            return true;
        if (!isBlank(str4))
            return true;
        return false;
    }

    public static boolean hasNotBlank(String str1, String str2, String str3, String str4, String str5) {
        if (!isBlank(str1))
            return true;
        if (!isBlank(str2))
            return true;
        if (!isBlank(str3))
            return true;
        if (!isBlank(str4))
            return true;
        if (!isBlank(str5))
            return true;
        return false;
    }

    public static boolean hasNotBlank(String str1, String str2, String str3, String str4, String str5, String str6) {
        if (!isBlank(str1))
            return true;
        if (!isBlank(str2))
            return true;
        if (!isBlank(str3))
            return true;
        if (!isBlank(str4))
            return true;
        if (!isBlank(str5))
            return true;
        if (!isBlank(str6))
            return true;
        return false;
    }

    public static boolean hasNotBlank(String str1, String str2, String str3, String str4, String str5, String str6, String str7) {
        if (!isBlank(str1))
            return true;
        if (!isBlank(str2))
            return true;
        if (!isBlank(str3))
            return true;
        if (!isBlank(str4))
            return true;
        if (!isBlank(str5))
            return true;
        if (!isBlank(str6))
            return true;
        if (!isBlank(str7))
            return true;
        return false;
    }


    public static boolean hasNotBlank(String str1, String str2, String str3, String str4, String str5, String str6, String str7, String str8) {
        if (!isBlank(str1))
            return true;
        if (!isBlank(str2))
            return true;
        if (!isBlank(str3))
            return true;
        if (!isBlank(str4))
            return true;
        if (!isBlank(str5))
            return true;
        if (!isBlank(str6))
            return true;
        if (!isBlank(str7))
            return true;
        if (!isBlank(str8))
            return true;
        return false;
    }


    public static boolean hasNotBlank(String str1, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9) {
        if (!isBlank(str1))
            return true;
        if (!isBlank(str2))
            return true;
        if (!isBlank(str3))
            return true;
        if (!isBlank(str4))
            return true;
        if (!isBlank(str5))
            return true;
        if (!isBlank(str6))
            return true;
        if (!isBlank(str7))
            return true;
        if (!isBlank(str8))
            return true;
        if (!isBlank(str9))
            return true;
        return false;
    }


    public static boolean hasNotBlank(String str1, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9, String str10) {
        if (!isBlank(str1))
            return true;
        if (!isBlank(str2))
            return true;
        if (!isBlank(str3))
            return true;
        if (!isBlank(str4))
            return true;
        if (!isBlank(str5))
            return true;
        if (!isBlank(str6))
            return true;
        if (!isBlank(str7))
            return true;
        if (!isBlank(str8))
            return true;
        if (!isBlank(str9))
            return true;
        if (!isBlank(str10))
            return true;
        return false;
    }

    private static void createNullCode(int paramCount) {
        String NLine = "\r\n";
        StringBuilder sb = new StringBuilder();

        sb.append("public static boolean hasNotNull(");
        int i;
        for (i = 1; i <= paramCount; i++) {
            if (i != paramCount) {
                sb.append("Object obj" + i + ",");
            } else {
                sb.append("Object obj" + i + "){").append(NLine);
            }
        }

        for (i = 1; i <= paramCount; i++) {

            sb.append("\tif ( obj" + i + " != null )").append(NLine);
            sb.append("\t\treturn true;").append(NLine);
        }
        sb.append("\treturn false;").append(NLine);
        sb.append("}").append(NLine);
        System.out.println(sb.toString());
    }

    private static void createBlankCode(int paramCount) {
        String NLine = "\r\n";
        StringBuilder sb = new StringBuilder();

        sb.append("public static boolean hasNotBlank(");
        int i;
        for (i = 1; i <= paramCount; i++) {
            if (i != paramCount) {
                sb.append("String str" + i + ",");
            } else {
                sb.append("String str" + i + "){").append(NLine);
            }
        }

        for (i = 1; i <= paramCount; i++) {

            sb.append("\tif ( !isBlank(str" + i + "))").append(NLine);
            sb.append("\t\treturn true;").append(NLine);
        }
        sb.append("\treturn false;").append(NLine);
        sb.append("}").append(NLine);
        System.out.println(sb.toString());
    }

    private static void createCompareEqualsCode(int paramCount) {
        String NLine = "\r\n";
        StringBuilder sb = new StringBuilder();
        sb.append("public static boolean compareHasEquals(String srcStr,");
        int i;
        for (i = 1; i <= paramCount; i++) {
            if (i != paramCount) {
                sb.append("String tag" + i + ",");
            } else {
                sb.append("String tag" + i + "){").append(NLine);
            }
        }
        sb.append("\tif(srcStr == null ) return false;").append(NLine);
        for (i = 1; i <= paramCount; i++) {
            sb.append("\tif(srcStr.equals(tag" + i + "))").append(NLine);
            sb.append("\t\treturn true;").append(NLine);
        }
        sb.append("\treturn false;").append(NLine);
        sb.append("}").append(NLine);
        System.out.println(sb.toString());
    }
}


